<g:setProvider library="jquery"/>
<g:javascript library="pages/user/createUser"/>

<div id="newUserDiv" class="body">
	<!-- TANCAR FINESTRA MODAL -->
	<g:if test="${userCreated}"><script type="text/javascript">closePopUp("#newUserDialog");</script></g:if>
	
	<!-- MISSATGES D'AVIS -->
    <g:if test="${flash.message}"><div class="message">${flash.message}</div></g:if>
    
    <!-- MISSATGES D'ERROR -->
    <g:hasErrors bean="${userInstance}">
    	<div class="errors"><g:renderErrors bean="${userInstance}" as="list" /></div>
    </g:hasErrors>
    <g:formRemote id="newUserFormModal" name="newUserFormModal" update="newUserDiv" url="[controller:'user',action:'save']" enctype="multipart/form-data">
        <div class="dialog">
            <table>
                <tbody>
                	<tr class="prop">
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'alias','errors')}">
                        	<label for="alias">Alias:</label>
                            <input type="text" id="alias" name="alias" value="${fieldValue(bean:userInstance,field:'alias')}"/>
                        </td>
                        
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'avatarPath','errors')}">
                            <label for="avatarPath">Avatar:</label>
                            <input type="file" id="avatarPath" name="avatarPath" value="${fieldValue(bean:userInstance,field:'avatarPath')}"/>
                        </td>
                    </tr>
                    
                    <tr class="prop">
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'password','errors')}">
                            <label for="password">Password:</label>
                            <g:passwordField id="password" name="password" value="${fieldValue(bean:userInstance,field:'password')}"/>
                        </td>
                        
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'password','errors')}">
                       		<label for="repeatPassword">Repeat Password:</label>
                            <g:passwordField id="repeatPassword" name="repeatPassword" value="${fieldValue(bean:userInstance,field:'password')}"/>
                        </td>
                    </tr>
                    
                    <tr class="prop">
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'name','errors')}">
                        	<label for="name">Name:</label>
                            <input type="text" id="name" name="name" value="${fieldValue(bean:userInstance,field:'name')}"/>
                        </td>
                        
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'lastName','errors')}">
                        	<label for="lastName">Last Name:</label>
                            <input type="text" id="lastName" name="lastName" value="${fieldValue(bean:userInstance,field:'lastName')}"/>
                        </td>
                    </tr> 
                
                    <tr class="prop">
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'email','errors')}">
                        	<label for="email">Email:</label>
                            <input type="text" id="email" name="email" value="${fieldValue(bean:userInstance,field:'email')}"/>
                        </td>
                        
                        <td valign="top" class="value ${hasErrors(bean:userInstance,field:'country','errors')}">
                        	<label for="country">Country:</label>
                            <g:countrySelect name="country" default="esp" value="${fieldValue(bean:userInstance,field:'country')}"/>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <input id="newUserHiddenSubmit" name="newUserHiddenSubmit" class="save" type="submit" style="display:none"/>
    </g:formRemote>
</div>
